﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MobilnyDostawca.ViewModels
{
    public class DostawcyEditViewModel : IValidatableObject
    {
        public int ID { get; set; } // id dostawcy
        public int Subregion { get; set; }
        public string Region { get; set; }
        public List<SelectListItem> Subregiony { get; set; }
        public bool IsValid { get; set; }

        public DostawcyEditViewModel() 
        {
            Subregiony = new List<SelectListItem>();
        }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            IsValid = true;

            if (this.Subregion == 0)
            {
                IsValid = false;
                yield return new ValidationResult("Wybierz poprawny subregion");
            }
        }
    }
}